<template>
  <div id="app">
    <!-- 顶部导航 -->
    <Topbar :key="topbarKey" />
    <!-- 头部nav链接 -->
    <Header />
    --
    <router-view @updateKey="updateKeyFn" />
    --
    <!-- 底部公共部分 -->
    <Footer />
    <!-- 登录 -->
    <Login v-show="isShowLoginModal" />
    <!-- 提示框 -->
    <transition name="slide">
      <Toast v-show="isShowToast" />
    </transition>
  </div>
</template>

<script>
import Topbar from "@/components/Topbar";
import Header from "@/components/Header";
import Footer from "@/components/Footer";
import Login from "@/components/Login";
import Toast from "@/components/Toast";
import { mapState } from "vuex";
import { JingPinAPI } from "@/request/api.js";
export default {
  data() {
    return {
      topbarKey: 1,
    };
  },
  components: {
    Topbar,
    Header,
    Footer,
    Login,
    Toast,
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },

  async created() {
    console.log(
      "输出环境变量值",
      process.env.VUE_APP_BASE_URL,
      process.env.VUE_APP_MY_TEST
    );
    // let res = await JingPinAPI();
    // console.log("res", res);
  },
  watch: {
    "$route.path": {
      handler(newVal, oldVal) {
        //   console.log("ap-watch");
        this.topbarKey++;
      },
    },
  },
  methods: {
    updateKeyFn() {
      this.topbarKey++;
    },
  },
};
</script>

<style lang="less">
/* 入场的起始状态 = 离场的结束状态 */
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
